package com.controller;

import com.common.paging.PagingData;
import com.service.ZzmService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.math.BigDecimal;

@RestController
@RequestMapping("query")
public class Zzmcontroller {

    @Autowired
    private ZzmService zzmService;

    /**
     * 查询提现详情
     * @param page 第几页
     * @param length  每页多少条
     * @return
     */
    @ApiOperation(value = "后台/查询提现")
    @PostMapping(value = "/findWithdraw")
    @ResponseBody
    public PagingData findWithdraw(Integer page, Integer length) {
        page = (page - 1) * 10;
        PagingData pagingData = zzmService.findWithdraw(page, length);
        return pagingData;
    }

    /**
     *修改提现状态
     * @param id :moneytobank ID
     * @return
     */
    @ApiOperation(value = "后台/修改提现状态")
    @PostMapping(value = "/updateWithdrawState")
    @ResponseBody
    public String updateWithdrawState(Integer id, Integer userId, BigDecimal money,Integer type){
       int res = zzmService.updateWithdrawState(id,userId,money,type);
        if (res == 1) {
            return "修改成功";
        } else {
            return "修改失败";
        }
    }

    //查询所有订单
    @ApiOperation(value = "查询所有订单总和")
    @PostMapping(value = "/findorder")
    @ResponseBody
    public int findorder(){
        return  zzmService.findorder();
    }


    /**
     * 领硬币代替RMB支付
     * @param userId  用户id
     * @param discountMoney  领英币
     * @return
     */
    @ApiOperation(value = "领硬币代替RMB支付")
    @PostMapping(value = "updateGoldPay")
    @ResponseBody
    public int updateGoldPay (Integer userId , BigDecimal discountMoney ){
       return zzmService.updateGoldPay(userId,discountMoney);
    }
}
